package com.example.demo.sys.controller;

import com.example.demo.sys.dao.SysRole;
import com.example.demo.sys.service.SysRoleService;
import com.example.demo.system.utility.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 角色类
 */
@RequestMapping("role")
@RestController
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    //列表查询
    @RequestMapping("getList")
    public Result getList(@RequestParam(value = "pageNum")Integer pageNum,
                          @RequestParam(value = "pageSize")Integer pageSize,
                          @RequestParam(value = "name", required = false)String name){
        return sysRoleService.getList(pageNum, pageSize, name);
    }

    //详情查询
    @RequestMapping("get")
    public Result get(Integer id){
        return Result.success(sysRoleService.get(id));
    }

    //新增
    @RequestMapping("add")
    public Result add(@RequestBody SysRole sysRole){
        return sysRoleService.add(sysRole);
    }

    //修改
    @RequestMapping("update")
    public Result update(@RequestBody SysRole sysRole){
        return sysRoleService.update(sysRole);
    }

    //删除
    @RequestMapping("delete")
    public Result delete(Integer id){
        return sysRoleService.delete(id);
    }

}
